package com.example.martin1e.ui.dashboard;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

import com.example.martin1e.R;


public class DashboardViewModel extends AppCompatActivity {

    private Spinner spinner;
    private TextView answer_1;
    private TextView answer_2;
    private String[] options = {"选项1", "选项2", "选项3"};
    private String[][] answers = {
            {"答案1-1", "答案1-2"},
            {"答案2-1", "答案2-2"},
            {"答案3-1", "答案3-2"}
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_dashboard); // 确保这是ShowActivity的布局文件

        // 初始化UI元素
        spinner = findViewById(R.id.id1_2); // 确保spinner的ID在activity_show.xml中定义
        answer_1 = findViewById(R.id.id2_2);
        answer_2 = findViewById(R.id.id3_1);

        answer_1.setText("answers1");
        answer_2.setText("answer2");
        // 设置Spinner的选择事件监听器
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                updateAnswers(position);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                // 处理没有选择任何项的情况（可选）
            }
        });
    }

    private void updateAnswers(int position) {
        answer_1.setText(answers[position][0]);
        // 可以在这里添加处理CheckBox状态的逻辑（如果需要）
    }
}